package com.zbkj.admin.task.cash;

import com.zbkj.common.utils.DateUtil;
import com.zbkj.service.service.UserCashRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 礼金冻结期解冻task
 *
 * @author Swallows
 * @date 2022-09-26 14:35
 */
@Slf4j
@Component
@Configuration
@EnableScheduling
public class CashFrozenTask {

    @Autowired
    private UserCashRecordService userCashRecordService;

    @Scheduled(fixedDelay = 1000 * 60L)
    public void init() {

        log.info("----- CashFrozenTask task------produce Data with fixed rate task: Execution Time - {}", DateUtil.nowDateTime());
        try {
            userCashRecordService.cashThaw();
        } catch (Exception e) {
            e.printStackTrace();
            log.error("CashFrozenTask.task" + " | msg : " + e.getMessage());
        }
    }
}
